package com.itboye.sunsun.adapter;

import java.util.List;

import com.itboye.sunsun.R;
import com.itboye.sunsun.address.ForumPostModel;
import com.itboye.sunsun.address.MyPostModel;
import com.itboye.sunsun.beans.OrderBean;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class MyPostAdaper extends BaseAdapter {
	/***
	 * 2016-03-04 论坛帖子
	 * 
	 * @author
	 */

	private Context context;
	private List<OrderBean> list;

	public MyPostAdaper(Context context, List<OrderBean> list2) {
		this.context = context;
		this.list = list2;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public int getItemViewType(int position) {
		// TODO Auto-generated method stub
		return position;
	}
//设置我的帖子下拉刷新返回的值
	public int getViewTypeCount(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		HandView mView;
		
		// /当控件为空时加载布局文件中item
		if (convertView == null) {
			mView = new HandView();
			// /////////得到Mypostitem界面
			convertView = LayoutInflater.from(context).inflate(
					R.layout.forum_post_item_andpost, null);
			ImageView post_item_zan=(ImageView) convertView.findViewById(R.id.post_item_zan);
			post_item_zan.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View arg0) {
					// TODO Auto-generated method stub
					Toast.makeText(context, "+"+1, 1).show();
				}
			});
			// 得到mypost头像id
		/*	mView.imghed = (ImageView) convertView
					.findViewById(R.id.img_post_hed);
			// 得到mypost用户呢称
			mView.postname = (TextView) convertView
					.findViewById(R.id.post_name);
			// 得到mypost时间
			mView.posttime = (TextView) convertView
					.findViewById(R.id.post_time);
			// 得到mypost加载内容
			mView.postcontent = (TextView) convertView
					.findViewById(R.id.post_content);
			// 得到mypost居左图片
			mView.imgleft = (ImageView) convertView
					.findViewById(R.id.img_post_leit);
			mView.imgcentent = (ImageView) convertView
					.findViewById(R.id.img_post_gheit);
			mView.imgright = (ImageView) convertView
					.findViewById(R.id.img_post_gheit);
			mView.zan = (ImageView) convertView
					.findViewById(R.id.post_item_zan);
			mView.ping = (ImageView) convertView
					.findViewById(R.id.post_item_ping);*/
		} else {
			// *** **/////
			mView = (HandView) convertView.getTag();
		}
		// /给给个item中控件进行赋值
//		mView.imghed.setImageBitmap(list.get(position).getImghed());
//		mView.postname.setText(list.get(position).getPostname());
//		mView.posttime.setText(list.get(position).getPosttime());
//		mView.postcontent.setText(list.get(position).getPostcontent());
//		mView.imgleft.setImageBitmap(list.get(position).getImgleft());
//		mView.imgcentent.setImageBitmap(list.get(position).getImgcentent());
//		mView.imgright.setImageBitmap(list.get(position).getRight());
//		mView.zan.setImageBitmap(list.get(position).getZan());
//		mView.ping.setImageBitmap(list.get(position).getPing());
		return convertView;
	}

	class HandView {
		private ImageView imghed;// 用户头像
		private TextView postname;// 名字
		private TextView posttime;// 时间
		private TextView postcontent;// 内容
		private ImageView imgleft;// 图片
		private ImageView imgcentent;//
		private ImageView imgright;
		private ImageView zan;// 赞
		private ImageView ping;// 评论
	}

}
